package com.cskaoyan.service;


import com.cskaoyan.bean.user.Collect;
import com.cskaoyan.bean.user.CollectExample;
import com.cskaoyan.mapper.CollectMapper;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author dww
 */

@Service
public class CollectServiceImpl implements CollectService{
    @Autowired
    private CollectMapper collectMapper;

    public List<Collect> getCollectList(Integer page, Integer limit, String sort, String order, Integer userId, Integer valueId) {
        PageHelper.startPage(page,limit,sort +" " + order);
        CollectExample example = new CollectExample();
        CollectExample.Criteria criteria = example.createCriteria();
        if(userId!= null){criteria.andUserIdEqualTo(userId); }
        if(valueId != null){ criteria.andValueIdEqualTo(valueId); }
        List<Collect> list=collectMapper.selectByExample(example);
        return list;
    }
}
